import { api } from "../Axios";
import _ from 'lodash';

export default {
  namespaced: true,
  state: {
    value: 'tableData',
    tableData: [],
  },

  getters: {
    getValue: function (state) {
      return state.value;
    }
  },//调用时要用this.$store.getters['molle/getValue']
  mutations: {
    updataTable: function (state, { arr }) {
      let tar = state.tableData
      tar.splice(0, tar.length)
      arr.forEach((v) => {
        tar.push(v)
      })
    }
  },
  actions: {
    getDateList(ctx, payload) {
      api.getTableData().then((res) => {
        if (res.data.length > 0) {
          return Promise.resolve(res.data)
        }
      }).then((res) => {
        ctx.commit('updataTable', { arr: res })
      })
    }
  },
}